﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Drawing.Imaging;
using System.IO;
using System.Drawing;
using DatabaseHelper;
using System.Net;
using Log;


namespace DataAccess
{
    public class DataAccess_Utility
    {
        public const string m_msg_head = "UTILITY";
        public static  byte[] GetByte(string pathImage, ImageFormat ImageType)
        {
            byte[] result = new byte[] { };
            if (File.Exists(pathImage))
            {
                Image img = Image.FromFile(pathImage);
                using (MemoryStream ms = new MemoryStream())
                {
                    img.Save(ms, ImageType);
                    result = ms.ToArray();
                    img.Dispose();
                }
            }
            return result;
        }

        public  DateTime GetDateServer()
        {
            DateTime result = new DateTime();
            string query = "select getdate() as [dateserver]";
            using (var db = new DbHelper())
            {
                var result1 = db.ExecuteScalar(query.ToString());
                result = Convert.ToDateTime(result1.ToString());
            }
            return result;
        }
    }
}
